<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <link rel="stylesheet" href="../../layui/css/layui.css" />
    <style>
        .layui-input {
            width: 220px;
        }
        .layui-form-item{
            margin-top: 5px;
            padding-bottom: 15px;
        }
    </style>
</head>
<body>
<form class="layui-form" action="" lay-filter="upd">
    <input type="hidden" id="aid" name="aid">
    <div class="layui-form-item">
        <label class="layui-form-label">账号</label>
        <div class="layui-input-inline">
            <input type="text" name="auser" id="auser" required  lay-verify="required"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="text" name="apassword" id="apassword" required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="aname" id="aname" required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-inline">
            <select name="asex" id="asex" lay-verify="required">
                <option value="男">男</option>
                <option value="女">女</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机</label>
        <div class="layui-input-inline">
            <input type="text" name="aphone" id="aphone" required  lay-verify="required|phone" autocomplete="off" class="layui-input">
        </div>
    </div>
    <input type="hidden" name="atime" id="test1">
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-inline">
            <input type="text" name="aemail" id="aemail" required  lay-verify="required|email" autocomplete="off" class="layui-input">
        </div>
    </div>
    <input type="hidden" name="aposition" id="aposition" value="1">
    <input type="hidden" name="asatus" id="asatus" value="0">
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="btn" class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="../../layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form','laydate','laydate'], function(){
        var form = layui.form;
        var laydate = layui.laydate;
        var $=layui.$;
        //监听提交
        form.on('submit(formDemo)', function(data){
            //通过ajax提交后台
            $.ajax({
                type:"post",
                url:"/admininsert",
                data:$('form').serialize(),
                //提交成功获取返回的数据
                dataType:'text',
                success:function(data){
                    if(data.code==0) {
                        layer.msg('新增成功')
                    }
                },
                error:function () {
                    layer.msg('新增失败')
                }
            })
            var index=parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
        var time=new Date();
        var date = time.getFullYear() + '-' + (time.getMonth() + 1) + '-' + time.getDate() + ' ' + time.getHours()
            + ':' + time.getMinutes() + ':' + time.getSeconds();
        laydate.render({
            elem: '#test1',    //指定元素test1
            value: new Date(new Date())
        });
        var a=$("#test1");
    });
</script>
</body>
</html>